package com.atguigu.srb.core.controller.api;


import com.atguigu.srb.core.pojo.entity.IntegralGrade;
import com.atguigu.srb.core.service.IntegralGradeService;
import com.atguigu.srb.result.ResponseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 积分等级表 前端控制器
 * </p>
 *
 * @author Atguigu
 * @since 2024-04-15
 */
// 普通用户访问的积分等级接口
@Api(tags = "普通用户访问的积分等级接口...")
@RestController
@RequestMapping("/api/core/integralGrade")
public class ApiIntegralGradeController {
    @Autowired
    private IntegralGradeService integralGradeService;
    @GetMapping
    public List<IntegralGrade> getAllIntegralGrade(){
        return  integralGradeService.list();
    }

    @ApiOperation("根据用户token查询借款额度")
    @GetMapping("borrowAmount")
    public ResponseVo getBorrowAmountById(@RequestHeader("token") String token){
        BigDecimal amount =  integralGradeService.getBorrowAmountByToken(token);
        return  ResponseVo.ok().addData("item",amount);
    }

}

